package com.ibiaoke.boss.controller;

import com.ibiaoke.common.base.BaseController;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.customer.entity.Customer;
import com.ibiaoke.goods.service.PtGoodService;
import com.ibiaoke.order.entity.PtOrder;
import com.ibiaoke.order.entity.so.SubmitOrderSO;
import com.ibiaoke.order.service.PtOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 拼团Controller
 */
@Controller
public class WxPtFightController extends BaseController{

    @Autowired
    private PtGoodService ptGoodService;

    @Autowired
    private PtOrderService ptOrderService;

    /**
     * 一键参团生成订单
     */
    @RequestMapping("/submitPtGoodsFlightOrder")
    @ResponseBody
    public Res submitPtGoodsOrder(SubmitOrderSO submitOrderSO,Integer ptGoodsId){
        Customer customer = getLoginUser();
        submitOrderSO.setUserId(customer.getCustomerId());
        submitOrderSO.setCustomerNickname(customer.getCustomerNickname());
        submitOrderSO.setUserNameImg(customer.getCustomerImg());
        PtOrder ptOrder = ptOrderService.submitPtGoodsFlightOrder(submitOrderSO,ptGoodsId);
        return Res.create().addResponse("ptOrder",ptOrder);
    }
}
